package com.yanfan.energy.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.energy.mapper.IbmsEnergyFlowMapper;
import com.yanfan.energy.domain.IbmsEnergyFlow;
import com.yanfan.energy.service.IIbmsEnergyFlowService;

/**
 * 能耗统计Service业务层处理
 *
 * @author genluo
 * @date 2024-11-14
 */
@Service
public class IbmsEnergyFlowServiceImpl extends ServiceImpl<IbmsEnergyFlowMapper, IbmsEnergyFlow> implements IIbmsEnergyFlowService {
    @Autowired
    private IbmsEnergyFlowMapper ibmsEnergyFlowMapper;


    /**
     * 查询能耗统计列表
     *
     * @param ibmsEnergyFlow 能耗统计
     * @return 能耗统计
     */
    @Override
    public List<IbmsEnergyFlow> queryPageList(IbmsEnergyFlow ibmsEnergyFlow) {
        LambdaQueryWrapper<IbmsEnergyFlow> lqw = buildQueryWrapper(ibmsEnergyFlow);
        return ibmsEnergyFlowMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return ibmsEnergyFlowMapper.queryPageList(ibmsEnergyFlow);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<IbmsEnergyFlow> buildQueryWrapper(IbmsEnergyFlow bo) {
        LambdaQueryWrapper<IbmsEnergyFlow> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getEnergyValue()), IbmsEnergyFlow::getEnergyValue, bo.getEnergyValue());
        lqw.eq(StringUtils.isNotBlank(bo.getEnergyDevice()), IbmsEnergyFlow::getEnergyDevice, bo.getEnergyDevice());
        lqw.like(StringUtils.isNotBlank(bo.getEnergyDeviceName()), IbmsEnergyFlow::getEnergyDeviceName, bo.getEnergyDeviceName());
        lqw.eq(StringUtils.isNotBlank(bo.getIdentifier()), IbmsEnergyFlow::getIdentifier, bo.getIdentifier());
        lqw.eq(bo.getEnergyTime() != null, IbmsEnergyFlow::getEnergyTime, bo.getEnergyTime());
        return lqw;
    }



}
